SHELL   = /bin/bash
LIBRARY = ../../../archive.dokk.org/library

# Convert PDF to TXT using LibreOffice
# pdf filename: "$<"
# txt filename: "$@"
pdf2txt : $(subst :,\:,$(patsubst %.pdf,%.txt,$(shell find "${LIBRARY}" -type f -name "*.pdf")))
%.txt : %.pdf
	@echo "Processing $<" 
	@pdftotext -layout "$<"

# Convert PDF to HTML using pdf2htmlEX
# pdf filename: "$<"
# html filename: "$@"
pdf2html : $(subst :,\:,$(patsubst %.pdf,%.html,$(shell find "${LIBRARY}" -type f -name "*.pdf")))
%.html : %.pdf
	@echo "Processing $<"
	@pdf2htmlEX --dest-dir "${LIBRARY}" --embed cFIJO "$<"
	./extract-background.py "$@"

clean:
	rm -f ${LIBRARY}/*.{css,html,js,txt}

.ONESHELL:
.SUFFIXES:
.PHONY:
.DELETE_ON_ERROR:
